<?
  include('../init.php');

  $pid = $_GET["pid"];
  $page = $_GET['page'];

  $url = $db->queryUniqueValue("SELECT url FROM picture WHERE pid = $pid");

  $db->execute("DELETE FROM picture WHERE pid = $pid");

  $url = str_replace("http://www.eventwhenwhere.com/","../../",$url);
  //$url = str_replace("http://127.0.0.1/chaos/","../../",$url);
  unlink($url);

  header("Location:index.php?page=$page");
?>